package com.um.jdy.platform.order.controller;


import com.um.jdy.platform.order.entity.dto.*;
import com.um.jdy.platform.order.entity.vo.OrderSummaryItemVO;
import com.um.jdy.platform.order.entity.vo.StationSummaryVO;
import com.um.jdy.platform.order.manager.OrderSummaryManager;
import com.um.springboot.starter.annotation.ApiPermission;
import com.um.springboot.starter.annotation.TokenRequired;
import com.um.springboot.starter.entity.Page;
import com.um.springboot.starter.orm.controller.BaseController;
import com.um.springboot.starter.orm.entity.Response;
import com.um.springboot.starter.orm.params.ExportParams;
import com.um.springboot.starter.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 控制器：订单佣金表
 */
@RestController
@RequestMapping("/api/v1/cms/order/summary")
@Api(tags = "佣金管理", description = "订单佣金表")
@ApiPermission("order_summary")
@TokenRequired
@Validated
public class OrderSummaryController extends BaseController<OrderSummaryManager> {

    /**
     * 站场订单统计列表
     * @param params
     * @return
     */
    @ApiPermission("page")
    @ApiOperation(value = "站场订单统计列表")
    @PostMapping("station_order_page")
    public Response<Page<OrderSummaryItemVO>> getStationOrderSummaryPage(@RequestBody StationOrderPageDTO params){
        return Response.success(manager.getStationOrderSummaryPage(params.getPageNo(),params.getPageSize(), StringUtil.getQueryParam(params.getName()),params.getYearOrMonth()));
    }

    @ApiPermission("export")
    @ApiOperation(value = "导出站场订单统计")
    @PostMapping("export_station_order_page")
    public Response exportStationOrderSummaryPage(@RequestBody ExportStationOrderPageDTO params) {
        ExportParams exportParams = params.toExportParams(new String[]{}, new String[]{});
        return manager.exportStationOrderSummaryPage(exportParams, params.getYearOrMonth(), params.getName());
    }

    /**
     * 查询站场明细订单列表
     * @param params
     * @return
     */
    @ApiPermission("list")
    @ApiOperation(value = "查询站场明细订单列表")
    @PostMapping("station_order_list")
    public Response<StationSummaryVO> getStationOrderDetailPage(@RequestBody StationOrderListDTO params){
        return Response.success(manager.getStationOrderDetailList(params.getDeviceStationId(),params.getType(),params.getYearOrMonth()));
    }

    /**
     * 分页查询运营商/商户佣金统计
     * @param params
     * @return
     */
    @ApiPermission("summary")
    @ApiOperation(value = "运营商/商户佣金统计")
    @PostMapping("/merchant_commission_page")
    public Response<Page<CommissionSummaryItemVO>> getSummaryPage(@RequestBody CommissionSummaryPageDTO params){
        return manager.getSummaryPage(params);
    }

}
